package org.jeecg.modules.system.util;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

public class PageUtil {

    public static <T> IPage<T> convertListToIPage(List<T> list, int current, int size) {
        if (list == null || list.isEmpty()) {
            throw new IllegalArgumentException("List must not be null or empty");
        }
        IPage<T> page = new Page<>(current, size);
        page.setRecords(list);
        page.setTotal(list.size());
        page.setSize(size);
        page.setCurrent(current);
        page.setPages((int) Math.ceil((double) list.size() / size));
        return page;
    }
}
